
* Plot of supported hypotheses
set scheme stcolor

use ../Metadata/tess_analysisdata.dta, clear	
	
cap frame change default
cap frame drop results
frame create results strL varname mean se ul ll str8 N color
	
	gen faculty = (title == 3 | title == 4 | title == 5)
	
	proportion hyp_true if faculty == 1 & insample == 1, level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results ("Faculty") (`mean') (`se') (`ll') (`ul') ("N=`N'") (1)

	proportion hyp_true if faculty == 0 & insample == 1, level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results ("Non-faculty") (`mean') (`se') (`ll') (`ul') ("N=`N'")	(1)

	gen multiauthor = numauthors > 1 if numauthors < .
		
	proportion hyp_true if multiauthor == 0 & insample == 1, level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results (`""Sole-" "authored""') (`mean') (`se') (`ll') (`ul') ("N=`N'") (2)

	proportion hyp_true if multiauthor == 1 & insample == 1, level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results ("Co-authored") (`mean') (`se') (`ll') (`ul') ("N=`N'")	(2)

	cap drop polisci
	gen polisci = (discipline == 5)
	
	proportion hyp_true if polisci == 1 & insample == 1, level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results (`""Political" "science""') (`mean') (`se') (`ll') (`ul') ("N=`N'")	(3)

	proportion hyp_true if polisci == 0 & insample == 1, level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results (`""Not political" "science""') (`mean') (`se') (`ll') (`ul') ("N=`N'")	(3)

	
	frame results {
		
		cap drop xlabel
		gen xlabel=_n
		labmask xlabel, values(varname)

		cap drop mlabel
		gen mlabel=0.025
		
		graph twoway ///
		(bar mean xlabel , barw(0.8) colorvar(color) colorlist(stc1%50 stc3%50 stc5%50 ) colordiscrete lc(none)) ///
		(rcap ll ul xlabel ,lc(gs7)) ///	
		(scatter mlabel xlabel , ///
msym(none) mlab(N) mlabpos(0) mlabcolor(black) mlabsize(5) mlabangle(hor)) ///
		, ///		
			ytitle("Pr(supported hypothesis)", size(5) margin(r=0)) ///
			xlabel(, labsize(5) angle(hor) valuelabel nogrid) ///
			xtitle(" ", margin(b=2)) ///
			ylabel(0(0.1).5, labsize(5) gmax gmin nogrid) ///
			title("{it: Hypothesis-level support}" " ", justification(left) position(11) span size(6)) ///
			graphregion(color(white)) ///
			scheme(stcolor) ///
			legend(off) clegend(off) ///
			xsize(4) ysize(2) 
			
		graph export ../Results/Figure4_top.tif, replace
	}
 
 
* study-level positive results
 use ../Metadata/tess_analysisdata.dta, clear	
	
cap frame change default
cap frame drop results
frame create results strL varname mean se ul ll str8 N color
	
	keep if hyp_num==1
	
	gen faculty = (title == 3 | title == 4 | title == 5)
	
	proportion successfulexp_insample if faculty == 1 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results ("Faculty") (`mean') (`se') (`ll') (`ul') ("N=`N'") (1)

	proportion successfulexp_insample if faculty == 0 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results ("Non-faculty") (`mean') (`se') (`ll') (`ul') ("N=`N'")	(1)

	gen multiauthor = numauthors > 1 if numauthors < .
		
	proportion successfulexp_insample if multiauthor == 0 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results (`""Sole-" "authored""') (`mean') (`se') (`ll') (`ul') ("N=`N'") (2)

	proportion successfulexp_insample if multiauthor == 1 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results ("Co-authored") (`mean') (`se') (`ll') (`ul') ("N=`N'")	(2)

	cap drop polisci
	gen polisci = (discipline == 5)
	
	proportion successfulexp_insample if polisci == 1 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results (`""Political" "science""') (`mean') (`se') (`ll') (`ul') ("N=`N'")	(3)

	proportion successfulexp_insample if polisci == 0 , level(83.4)		
	mat table = r(table)	
	local mean = table[1,2]
	local se = table[2,2]
	local ll = table[5,2]
	local ul = table[6,2]
	local N	 = table[7,1]+1		
	frame post results (`""Not political" "science""') (`mean') (`se') (`ll') (`ul') ("N=`N'")	(3)

	
	frame results {

		cap drop xlabel
		gen xlabel=_n
		labmask xlabel, values(varname)

		cap drop mlabel
		gen mlabel=0.05
		
		graph twoway ///
		(bar mean xlabel , barw(0.8) colorvar(color) colorlist(stc1%50 stc3%50 stc5%50)  colordiscrete lc(none)) ///
		(rcap ll ul xlabel ,lc(gs7)) ///	
		(scatter mlabel xlabel , ///
msym(none) mlab(N) mlabpos(0) mlabcolor(black) mlabsize(5) mlabangle(hor)) ///
		, ///		
			ytitle("Pr(positive result)", size(5) margin(r=0)) ///
			xlabel(, labsize(5) angle(hor) valuelabel nogrid) ///
			xtitle(" ", margin(b=2)) ///
			title("{it: Study-level positive result}" " ", justification(left) position(11) span size(6)) ///
			ylabel(0(0.2)1, labsize(6) gmax gmin nogrid) ///
			graphregion(color(white)) ///
			scheme(stcolor) ///
			legend(off) clegend(off) ///
			xsize(4) ysize(2) 
	
		graph export ../Results/Figure4_bottom.tif, replace
	
	}
 
